<html>
<head>
	<title>Excersise 1</title>
	<link href="styles/js-console.css" rel="stylesheet" />
</head>
<body>
	<div id="js-console"></div>
	<script src="scripts/js-console.js"></script>
	<script>
		 function getPoint(x,y) 
		 {
    		return { x: x, y: y };
		 }

		function getLine(p1, p2)
		{
    		return { pointA: p1, pointB: p2 };
		}

		function calculateDistance(p1, p2) 
		{
    		return Math.sqrt((p1.x - p2.x) * (p1.x - p2.x)+ (p1.y - p2.y) * (p1.y - p2.y));
		}

		function IsPossibleFormingATriangle(line1, line2, line3) 
		{
    		var a = calculateDistance(line1.pointA, line1.pointB);
    		var b = calculateDistance(line2.pointA, line2.pointB);
    		var c = calculateDistance(line3.pointA, line3.pointB);
    		if (a + b > c && a + c > b && b + c > a) 
			{
        		jsConsole.writeLine("lines can form triangle");
    		} 
    		else 
			{
        		jsConsole.write("lines can`t form triangle");
    		}
		}

		var p1 = getPoint(2, 2);
		var p2 = getPoint(3, 3);
		var p3 = getPoint(4, 4);

		var l1 = getLine(p1, p2);
		var l2 = getLine(p2, p3);
		var l3 = getLine(p1, p3);

		var distance = calculateDistance(p3, p2);
		jsConsole.writeLine("The distance between p3 and p2 is: "+distance+" cantimeters");


		jsConsole.writeLine(IsPossibleFormingATriangle(l1, l2, l3));

	</script>
</body>
</html>
